package localdatetime01;

import java.time.LocalDateTime;

/*
  LocalDateTime:
     封装的是年月日时分秒，毫秒，纳秒
           2007-12-03T10:15:30。
       1.获取功能
           static LocalDateTime now()
           int getYear()
           Month getMonth()
           int getDayOfMonth()
           int getHour()             //获取小时
           int getMinute()           //获取分钟
           int getSecond()           //获取秒
           int getNano()             //获取纳秒
       2.设置功能
           static LocalDateTime of(int year, int month, int dayOfMonth, int hour, int minute)
           LocalDateTime withHour(int hour)
           LocalDateTime withMinute(int minute)
       3.判断功能
           public boolean isEqual(ChronoLocalDateTime<?> other)  //判断两个日期是否相等
 */
public class LocalDateTimeDemo01 {
    public static void main(String[] args) {
        //method01();

        //method02();

        LocalDateTime now1 = LocalDateTime.of(2013, 11, 12, 14, 20);
        LocalDateTime now2 = LocalDateTime.of(2014, 11, 12, 14, 20);
        System.out.println(now1.isEqual(now1));
        System.out.println(now1.isEqual(now2));
    }

    private static void method02() {
        LocalDateTime dateTime = LocalDateTime.of(2013, 11, 12, 14, 20);
        System.out.println(dateTime);

        System.out.println(LocalDateTime.now().withHour(15).withMinute(33));
    }

    private static void method01() {
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);//2023-11-02T21:59:26.37049
        System.out.println(now.getYear());
        System.out.println(now.getMonth());
        System.out.println(now.getDayOfMonth());
        System.out.println(now.getHour());
        System.out.println(now.getMinute());
        System.out.println(now.getSecond());
    }
}
